'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 抽奖奖励子项
 * @author sundbcn@gmail.com (sun debing)
 */

var mongoose = require('mongoose');

///////////////////////////////////////////////////////////
/**
 * 抽奖奖励子项
 * @type {mongoose}
 */
var luckItemSchema = new mongoose.Schema({
    // 奖励类型
    reward_type: {
        type: Number,
        default: 0
    },

    // 奖励
    reward: {
        type: Number
    },

    // 奖励个数
    reward_num: {
        type: Number
    },

    // 奖励值
    reward_value: {
        type: Number
    },

    // 是否打开
    open: {
        type: Number,
        default: 0
    }
});

/**
 * 获取奖励类型
 * @return {[type]} [description]
 */
luckItemSchema.methods.getRewardType = function () {
    return this.reward_type;
};

/**
 * 获取奖励
 * @return {[type]} [description]
 */
luckItemSchema.methods.getReward = function () {
    return this.reward;
};

/**
 * 获取奖励个数
 * @return {[type]} [description]
 */
luckItemSchema.methods.getRewardNum = function () {
    return this.reward_num;
};

/**
 * 获取奖励的值
 * @return {[type]} [description]
 */
luckItemSchema.methods.getRewardValue = function () {
    return this.reward_value;
};

/**
 * 是否已经打开
 * @return {[type]} [description]
 */
luckItemSchema.methods.isOpen = function () {
    return this.open;
};

/**
 * 设置为开启
 */
luckItemSchema.methods.setOpen = function () {
    this.open = 1;
};

if (!luckItemSchema.options.toJSON) {
    luckItemSchema.options.toJSON = {};
}
/* jshint unused:false */
luckItemSchema.options.toJSON.transform = function (doc, ret) {
    delete ret._id;
};

module.exports = luckItemSchema;
